import java.io.IOError;

public class Demo1 {
    private static Object locker1=0;

    private static Object locker2=0;
    public static void main(String[] args) throws InterruptedException {
        Thread t1=new Thread(()->{
          synchronized (locker1){
                System.out.println("t1加锁 locker1完成");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (locker2){
                    System.out.println("t1加锁 locker2完成");
                }
            }

        });
        Thread t2=new Thread(()->{
            synchronized (locker1){
                System.out.println("t2 加锁 locker1完成");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (locker2){
                    System.out.println("t2 加锁locker2 完成");
                }
            }
        });
        t1.start();
        t2.start();
    }
}
